#include "ThreadPool.h"

int cdFunc(const char* user, const char* arg, int* curr_folder, MYSQL* mysql){
    int realId = getAbsolutePath(*curr_folder, arg, user, mysql);
    if(realId == -1){
        return -1;
    }
    
    char sql[4096] = {0};
    sprintf(sql, "select * from virtual_file where id = %d and type = 'd' and tomb = 0;", realId);
    printf("cdFunc:sql = %s\n", sql);
    int Mret = mysql_query(mysql, sql);
    MYSQL_QUERY_CHECK(Mret, mysql);

    MYSQL_RES* result = mysql_store_result(mysql);
    if(mysql_fetch_row(result) == NULL){
        return -1;
    }

    *curr_folder = realId;
    return 0;
}
